package com.lineage.server.serverpackets;

import com.lineage.data.event.GamblingSet;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.templates.L1Gambling;
import java.util.Iterator;
import java.util.Map;

public class S_ShopBuyListGam extends ServerBasePacket {
  private byte[] _byte;
  
  public S_ShopBuyListGam(L1PcInstance pc, L1NpcInstance npc, Map<Integer, L1Gambling> sellList) {
    this._byte = null;
    writeC(65);
    writeD(npc.getId());
    if (sellList.isEmpty()) {
      writeH(0);
      return;
    } 
    if (sellList.size() <= 0) {
      writeH(0);
      return;
    } 
    writeH(sellList.size());
    Iterator<Integer> iterator = sellList.keySet().iterator();
    while (iterator.hasNext()) {
      Integer itemobjid = iterator.next();
      writeD(itemobjid.intValue());
      L1Gambling gam = sellList.get(itemobjid);
      int adena = (int)(GamblingSet.GAMADENA * gam.get_rate());
      writeD(adena);
    } 
    writeH(7);
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
